package com.yanqu.road.server.cmd.activity.douluodalu;

import com.yanqu.road.utils.YanQuMessageUtils;
import com.yanqu.road.pb.activity.douluodalu.DouLuoDaLuProto;
import com.yanqu.road.server.cmd.CrossUnionCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.logic.MessageHelper;
import com.yanqu.road.server.manager.douluodalu.CrossDouLuoDaLuMgr;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = Protocol.C_DOU_LUO_DA_LU_GET_WIN_REWARD, desc = "领取连胜奖励")
public class CrossDouLuoDaLuGetBattleWinRewardCmd extends CrossUnionCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {

        DouLuoDaLuProto.DouLuoDaLuGetBattleWinRewardCrossReqMsg reqMsg = DouLuoDaLuProto.DouLuoDaLuGetBattleWinRewardCrossReqMsg.parseFrom(packet.getBytes());
        int patronsExp = reqMsg.hasPatronsExp() ? reqMsg.getPatronsExp() : 0;
        String rewards = reqMsg.hasRewards() ? reqMsg.getRewards() : "";
        int winTimes = reqMsg.getWinTimes();
        MessageHelper.sendPacket(serverId, packet.getPlayerId(), YanQuMessageUtils.buildMessage(Protocol.S_DOU_LUO_DA_LU_GET_WIN_REWARD_FROM_CROSS,
                CrossDouLuoDaLuMgr.getBattleWinReward(reqMsg.getActivityId(), packet.getPlayerId(), patronsExp, rewards, winTimes, reqMsg.getBoxId(), reqMsg.getOtherRewardsList())));

    }

    @Override
    public void sendData() {

    }
}
